As of 2016-02-26, there will be no more posts for this blog. s/blog/pba/
Showing posts with label X Window. Show all posts

KOULES is a space action game, that you bump your enemies, the KOULES spheres, to death. Well, or the other way around.

https://lh3.googleusercontent.com/-ybB5bWNb578/VqvYJnteoII/AAAAAAAAJE8/wo6XOVMburg/s800-Ic42/koules.gif

Its an addictive game, you can play alone or with friends up to five for deathmatch or cooperative. For single player, it has 100 levels and 5 difficulty levels.

The game has 256-color mode in 640x480, monochrome, or black/white mode. It can also run a server and accept other players from clients. It can be played with keyboard, mouse, or joysticks.

The opening Star Wars crawl is interesting, so is the README and the official website. You may also want to read the Koules.FAQ.

KOULES was created by Jan Hubička in July, 1995, written in ANSI C with SVGAlib/X11, run on Unix-like or OS/2 Warp, under GPLv2, currently Debian version 1.4-23 (2015-05-02, post v1.4(1998-03-09)).

Back into Orbit is a fun shooter game in X Window, said a simple isometric shooter roguelike.

https://lh3.googleusercontent.com/-gpXg4RYyeeQ/VqL6PgdMtAI/AAAAAAAAJBg/W-_etU9ni4Y/s800-Ic42/back_into_orbit.gif

You shoot some black robots and green device which generates some kind of wave harming your health if you stay within the range. There is also different colors of cones that transport you to different locations. Some are really bad as you are ambushed.

Enemies and devices might drop coins, which might be used in a shop area. Never lived that long to try. The bigger robots shoot.

Back into Orbit was created on 2015-06-11, written in C with SDL2, GLEW, OpenGL 2.0+, and Assimp (Open Asset Import Library) under GPLv2, running on Linux and Windows, currently git-dc03083 (2016-01-21).

boom (GitHub) is

A 2-player battle game made for Ludum Dare 28 (December 2013), for the theme you only get one.
https://lh3.googleusercontent.com/-yA_yyT1OeKU/VmirxGUdJEI/AAAAAAAAImY/2PfIFmLdyLw/s800-Ic42/boom.gif

The game goes like this, two players, each has many fake mine and one possibly real mine, but you never know if you get the real real mine until the detonation of the possibly real mine.

It can be played with keyboard or Xbox 360 controllers and it has sound.

You lay as many mines as you like, and hope your opponent will come close near the possibly real mine and you detonate the mines. If its real, you win. If its not, you can still play cool since your opponent has not yet deploy the real mine and still doesnt know that is a real deal. If your opponent detonates the real mine and doesnt blow you up, then you are the winner.

Its a fun game.

boom was created on 2013-12-13 by Joseph Lansdowne, written in Python 2/3 and C with Pygame under the GPLv3, currently git-a0fb8ac (2014-01-18).

Cangkufan is a Sokoban clone with 50 puzzles by Hiroyuki Imabayashi.

https://lh3.googleusercontent.com/-g2u2WXlQgb0/VmTxBw6iTYI/AAAAAAAAIlo/vaoAeEydhiY/s800-Ic42/cangkufan.raw.gif

The controls include mouse and keyboard, you can undo or redo, replay best pushes or steps, which are recorded. The Cangkufan is the Chinese Pinyi of the Japanese (Kanji) title, in short, the Chinese pronunciation of 倉庫番.

Cangkufan was created by Pluto Yang in 2003, written in C with GTK+2 under the GPLv2, currently version 0.2 (2010-09-17).

Unintentional Christmas Tree is a fun and small arcade action puzzle game. You just lay the same color blocks on top of each other.

https://lh3.googleusercontent.com/-c0LR-X__54w/VmEBiYhUysI/AAAAAAAAIkk/7k6s-tpLwks/s800-Ic42/christmas.raw.gif

It has two modes, easy and hard. In hard mode, you cant make any mistakes, e.g. red on green, or that would be game over. In easy mode, lets just say that you can break this tree really easily.

Unintentional Christmas Tree was created by Joseph Lansdowne on 2012-02-27, written in Python 2 with Pygame under New BSD License (3-clause), currently git-da562ee (2012-02-27).

The question is not red or green but left or right.

Rescue Girlies is a fork of SuperTux by a father, R. Bassett Jr., in AugustDecember, 2013, he said:

I made RG as a Christmas gift for my children. Run, jump and think your way through the campaign to save your loved ones. Make new friends, eat some cupcakes, and squish many bad guys along the way!
https://lh3.googleusercontent.com/-Sk43SFp42ys/VluPiACoLaI/AAAAAAAAIio/mehuVkDaLNM/s800-Ic42/RescueGirlies.gif

Watch this video for more.

You must read the story that this father tells his daughters in the video with his own voice, really telling the story, this has to be one of the best Christmas gifts you can get when you are a kid.

Rescue Girlies was forked off SuperTux 0.3.3 (2010-08-06) by R. Bassett Jr., written in C++ with SDL under the GPLv3, currently git-bd68ac8 (2015-01-21)

GNUjump is a clone of xjump aka. FALLING TOWER, it uses SDL and has a lot of more options, it also supports multiplayer.

https://lh3.googleusercontent.com/--OrN2yz_Yqs/VlJUv2uSSGI/AAAAAAAAIdI/N7_9A5zj5XE/s800-Ic42/GNUjump-wincrash.gif

GNUjump 1.0.8 with wincrash theme, watch in SDLjump theme

It has much more options, you can change game settings, such as FPS and trailing effect; video, such as using OpenGL and antialiasing; and sound volumes. Beside the must-have high scores, a replay feature, so you can watch other peoples playing.

The sound effect is hilarious, not your usual sounds, but someones vocals, watch the video and you will hear those.

Here are the four themes.

Tower of Mediocrity is a tower defense game with ncurses and SDL backends.

Note

You should play this music while reading, which is played in the game.

https://lh3.googleusercontent.com/-Cfdk_4-mntc/Vk6N14WQ8QI/AAAAAAAAIYg/VB023QqvBPQ/s800-Ic42/mediocrity.gif

Click to watch whole the map played

You are in Mediocrity Central and the chatter says that some group is going to invade the Mediocrity Treasury, you job is to define while they crawling through the oddly built and hardly straight passageways through the city.

The following screenshot is of SDL backend, the bad guys are smiling devilishly, and the towers are bold-underline-strikeout icons for font styles as in word processors, WTF?

https://lh3.googleusercontent.com/-w_7-h7OVWVk/Vk6Nhcdl8FI/AAAAAAAAIYM/ClDnQIrWNxA/s800-Ic42/2015-11-20--10%25253A39%25253A06.png

xjump is a jumping platform game, all you do is jump and jump and jump.

https://lh3.googleusercontent.com/-ObQ6vY7Ss18/VkgjJMN_u6I/AAAAAAAAISU/8W9ynNTIut8/s800-Ic42/xjump.gif
https://lh3.googleusercontent.com/-yck7Av-gax4/VkgjI6GFKOI/AAAAAAAAISM/hwIKgrtsk_s/s400-Ic42/xjump.themes.gif

Default, Ion, and Jump n Bump

Its fairly easy to play and also easy to fall of edges, wasd, hjkl, or arrows to move or jump, also Space to jump and P to pause or resume.

There is a timer ticking, and slowly you will be forced to go up and only up, falling back down wont be a platform to catch you. It comes with three themes as you can see on the right.

Not really sure why its also named FALLING TOWER, because you will fall of the platforms of a tower?

I was really bored and somehow I decided to make a heatmap out of X cursor position in terminal. The following image shows the result and here is a video:

https://lh6.googleusercontent.com/-Iqlh5J3Relc/UmJgkhY9XQI/AAAAAAAAFQ4/fUdM-1pGQo4/s800/xcinfo-heatmap.png

This is just for fun, nothing really useful. The X cursor position is translated into terminal window space, then heating up and the heat would also cool down as time goes by. The heat scale is the rainbow hues, which I roughly calculated into 256 terminal colors.

If you are interested in xcinfo, it might be useful if you need to script with X cursor infomation. I had not touched the code more than a year ago until now.

I did my weekly system update about 13 hours ago and finally needed to reboot about 2 hours ago. After reboot, I had no X window for almost one hour before I finally found the problem.

At first, I only noticed:
No screens found.
Trying to read forums posts in a 80x24 console using elinks, do you have any idea how hard it is? And it didn't resolve the issue. I tried to downgrade xorg-server, but not xf86-video-ati, which is the actual cause.

I stumbled across the release announcement of version 7.0.0, it says
This is the first KMS only release.  Major changes:
- - Enable 2D tiling by default on r6xx+ asics
  (requires mesa 9.0+).  If you are planning to
  ship xf86-video-ati 7.x with an older version of
  mesa, please disable 2D tiling.
- - xserver 1.13 support including prime
- - glamor support
- - SI support
KMS (Kernel modesetting) only, finally, something makes sense with another message:
[    76.379] (II) [KMS] drm report modesetting isn't supported.
When you put two and two together, it's Eureka! I know my system has no KMS and this must be it, I knew it and I was right.

I re-emerged libdrm with USE flag libkms and rebuilt kernel for necessary changes. Be sure to have framebuffer part done correctly and have firmware installed if you have newer cards, or you will get black console.

After reboot, I can run X again. Somehow, X looks even more beautiful than ever.

You can imagine that I wondered why I didn't get any message from emerging 7.0.0, there should be a small note or an eselect news, but nothing. KMS-only, that's quite a big change.

I guess I am probably a few people who would have encountered this issue, now everyone probably has KMS enabled already. I had been late for many years. Finally, I have KMS, too.

One hour loss, well, not too bad. If anything ever happens again to X Window, I will have 210x65 (1680x1050) console, pretty! But let's hope it won't come to that.

2012-11-21T02:37:36Z: I just noticed that when I booted into X, the memory usage is only 48MB, used to be 72MB. Don't know if that's because of KMS or new X stuff updates.

Before I moved xcinfo to Bitbucket, I had already written script to plot the trail of my mouse movement. The following image demonstrates the movements of 4 hours:

http://2.bp.blogspot.com/-pIuZmkxPwXU/T5XhWHHA20I/AAAAAAAADQo/_I5twVL5Pvk/s800/test.png

For every position my mouse at on screen, it will be render as a circle (radius = 10 pixels) with radical gradient, the position is polled every 0.1 seconds. For consecutively same position is only rendered once.

From what I see, the high density are seem to be around little to the right and bottom of center pointer. This area probably is where I usually have the focus of web page placed and click up on if I do.

Also a horizontal line near on the top edge, and you can also see there is actually a space in the line, thats because I use dwm and usually I have two windows vertically split. That line should indicate my movement over Firefoxs tab handlers.

4 hours would have 4 * 3600 * 10 = 144,000 points at most. If we roughly count the redundant rate is 90%, then its about 14,400 point rendered. But I dont think mine is lower then that. And clearly, there are a vast region which my mouse has never visited because there is no need to when you use tiling window manager and mainly use mouse to control windows.

You can get the code and make one of your own, please head over to project repository and read mouse trail subsection in Examples section.

xcinfo is a utilization I use for bzen2, it was hosted on GitHub alongside my dotfiles. Because of this one-liner, I decided to move it to its own repository and expand it with a few examples.

That one-liner snaps a screenshot after detecting mouse movements. I like this idea, though it has no use for me. I think its more or less for security measure. The method it uses is to read the device file of X pointer, it has pros but also the cons. I decided to write an alternative using xcinfo, which becomes an example of xcinfo.

I am sure some of you who write shell scripts has hard time to get X cursor information, mainly the X and Y position. I was not aware of any handy program for getting those two numbers. Thats why I wrote that little C code in the first place last year.

The information which xcinfo provides should cover most of your usage, the cursor position and screen size. If you need more, open a feature request issue, I will see what I can do about. A pull request, that would be even better.

By the way, I have also worked on a fun example, you can also read the examples section on project website.

Back in December, 2008, I posted Proper way to turn on SHMConfig in X Server 1.5 with input hotplugging, that was when HAL had not been deprecated. I checked my un-merging log, HAL was removed from my system in December, 2010, two years later of the post.

According to man synaptics, since X server 1.6, you don't need SHMConfig for changing settings on the fly via synclient. However, the -m touchpad activity monitoring option still requires SHMConfig, or you will get the same old error message:
Can't access shared memory area. SHMConfig disabled?
I have a plan for monitoring activity of touchpad, so I tried to turn it on again and the proper way is to edit /usr/share/X11/xorg.conf.d/50-synaptics.conf:
Section "InputClass"
        Identifier "touchpad catchall"
        Driver "synaptics"
        MatchDevicePath "/dev/input/event*"
        MatchIsTouchpad "on"
        Option "SHMConfig" "on"
EndSection
The lines in bold text were what I added to it, the rest were the original content. I found out /dev/input/event* is crucial to get SHMConfig turned on. Without it, I still got the same error message saying SHMConfig disabled. I don't know if it also affects other options, but you don't actually need to put touchpad options here, you can change in your ~/.xinitrc or write a startup script.

If you don't have the file, then just create one in the same directory or one listed in man xorg.conf, X server looks into many different directories for configuration files.

If you check your home directory and see a lot of \.serverauth\.\d+ files, they are the files left after your X window has an unexpected exit or system crashes except one is currently being used.

I found a nice explanation of the situation, this doesn't happen to all users, only those who relies on startx. I added a simple code in my ~/.xinitrc because I don't want to touch system file as you read what that article tells you how to get rid of them by modifying /usr/bin/startx, so you can have a singular server authentication file.

Here is what I am using:
# clean up serverauth files, which were left due to unexpected exit of X window
for sa in ~/.serverauth.*; do pid=${sa/*.serverauth./}; [[ ! -d /proc/$pid ]] && rm ~/.serverauth.$pid; :; done
unset sa pid
It checks if the PID associated with the server authentication file exists, leave it alone if so, or remove the file. Of course, there is possibly false confirmations on PID of different process, but it does no harm except the file still remains. Eventually, you will cleaned them up all.

After I added a keybinding for Bash, I think why not make it working globally?

Here is what I just added to my DWM configuration:

diff --git a/dwm-config.h b/dwm-config.h
index 1994463..517976b 100644
--- a/dwm-config.h
+++ b/dwm-config.h
 -125,6 +125,8  static const char *monitor_expand_cmd[] = { "monitorExpand.sh", NULL };

 static const char *lock_cmd[] = { "xlock", "-mode", "blank", "-startCmd", "monitorOff.sh", "-timeout", "15", "-dpmsoff", "1", NULL };

+static const char *ts_cmd[] = SHCMD("xdotool keyup t ; xdotool type --clearmodifiers $(date --utc +%Y-%m-%dT%H:%M:%SZ)");
+
 static Key keys[] = {
   /* modifier                     key         function        argument */
   { MODKEY,                       XK_p,       spawn,          {.v = bashrun_cmd } },
 -155,6 +157,8  static Key keys[] = {
   { MODKEY,                       XK_F2,      spawn,          {.v = monitor_switch_cmd} },
   { MODKEY,                       XK_F3,      spawn,          {.v = monitor_expand_cmd} },

+  { MODKEY|ShiftMask,             XK_t,       spawn,          {.v = ts_cmd} },
+
   { MODKEY|ShiftMask,             XK_m,       toggle_ffm,     {0} },
   { MODKEY|ShiftMask,             XK_r,       toggle_rules,   {0} },

It uses xdotool to send the key events. Since I bound it to t, it is necessary to send a keyup even in prior or the timestamp string will be eaten entirely or partially, depending on when I release the key. Also, --clearmodifiers is required, or the characters in timestamp string may trigger other keybindings in DWM.

You can bind the key in your Window Manager, some may not be able to run with sh but a simple executable file, you can always create a script and put the commands in that script and make it executable.

dwm stands for Dynamic Window Manager, its a dynamic tiling WM. Current stable version is 5.9, but I am using version 5.6.1, a two-year-old version, because its stable version in Gentoo.

https://lh6.googleusercontent.com/-OCbHsOhPgkE/Tie93f6lXxI/AAAAAAAACzU/efe-3B8hFyQ/s800/2011-07-21--13%25253A47%25253A55.png

Current view with tag 1 and q (KeepNote tagged with) on and layout is bstack (bottom stack). That video is just an example, no one cant even do anything with that video being played. Nyan!

1   Why I switched to dwm

My previous WM is Fluxbox and its really a great WM, I had been using it for more than two years. I like it, still do, even now I has switched to dwm. But from time to time, stacking window manager just can make you take some time to move and to resize windows, only to satisfy unnecessary adjustment. Its as if you wrote one paragraph and take three times of time of writing that paragraph to change text color/style/etc. Like TeX, you are educated to focus on your content, instead. Using tiling window manager, it makes you try less to adjust window size, to align the windows, if you used to line up windows side by side. Many stacking WM supports snapping (dwm does, too), which is helpful for arranging windows, but you might not be happy with the size of the window. So, you go back to maximize all windows, then you might keep pressing Alt+Tab to bring the underneath window to top.

I need to have more than one window to be shown at the same time, tiling would help a lot. And thats the reason that I switched to dwm. However, dwm wasnt the first tiling window manager I have tried, awesome was the first. But at the time, I didnt really get the concept. When I decided to find one to try again, dwm is one of many WM needs very less dependency. No need to learn scripting language, you just use C.

When I firstly tried, I also heard of dwm, but I didnt want to compile. Now, I prefer to compile a C program instead of using Python script or so. Compiled program should have better performance than interpreted language program. dwm is little more, it doesnt use a structured configuration file. Actually, a C code is still one, its just being parsed and compiled.

Of course, it lacks of certain flexibility since recompilation is required in order to have new configuration, in fact, restart the program is also required. However, the code of dwm is only around 2,000 lines plus your configuration C code, the compilation time is extremely fast. And once you have stable configuration, you probably wouldnt make and changes for a few months.

2   Previous experience with tiling WM

I have to admit that this wasnt my first time to try a tiling WM as I mentioned above. My first experience was with awesome. If I recall correctly, its about one week before I switched back to Enlightenment E16. I couldnt get a hold of tiling WM at that moment, too many keybinds to remember. Funny thing is that I feel I now have configured more keys than I had with awesome. Maybe its just I didnt understand the concept of tiling or how to really make a use of it.

Another one is PyTyle, its used on top of non-tiling WM, an addon. Ten-minute with it, I guess.

3   How I use dwm

3.1   The terms: client, tag, layout, view, monitor

Before I am going to get into that, there are some terms have to be explained first. If you are familiar with those, then skip this subsection.

Client is a window (program), something you spawn with, say dmenu or your favorite program launcher or you keybind for a special program in dwm. It stays in its own cell in dwm. A client must be tagged with a least one tag. By default, it will be currently viewed tag.

A view can show multi-tag at the same time, and the clients tagged with those tags will be presented with selected layout. The default available layouts, in v5.6.1, are tiling, floating, and monocle. Layout is independent from view, that is changing view doesnt cause layout change, vice versa.

One monitor can only have one view, but previous view can be brought back.

3.2   So, how?

The default tag list is 1 2 3 4 5 6 7 8 9, but Ive changed it to 1 2 3 q w e a s d. Notice where they are located on keyboard? They are in 3x3 square shape, well, sort of.

The first three 1 2 3 is used as if they are workspace, I name them workspace tags. I compose, grope, or tag clients with them. When a client is tagged with them, they have already been tagged with only one of q w e a s d, which I call them client tags.

In my rules, please see my configuration, programs I used to use are tagged with client tags. Those programs will always be spawned with generally only one of client tag, but none of workspace tags. For those are not listed in rules, they are spawned with currently viewed tag, and thats reason I always make sure my currently viewed tag is one of 1 2 3. That way, I wont have unwanted program being tagged with client tags.

Once a program spawned, I can bring one of client tags to currently viewed tag by pressing ModKey+Ctrl+Tag, then tag the program I need to current workspace tag and turn off the client tag. Or I can just switch to that client tag and tag that program, then switch back.

Most of time, my tag 1 has Firefox, terminal, and video player; tag 2 has the same Firefox and KeepNote. When I need to code, I stay at tag 1; when I need to check up my notes, I switch to tag 2. If the space isnt the issue, I just bring tag 2 to current view, so I can see all programs tagged with 1 and 2.

However, I do not always stick with these workspace tags. Some of programs I use in client tag, e.g. GIMP. If needed I can temporarily bring the tag with GIMP, then turn off after I am done. Since I keep GIMP in its own client tag, I dont need to worry that I would bring other programs with it. Thats why I decide to categorize program into their own client tags.

There is plenty of ways to use dwm, it depends how you like to do, no strict rules tell how you should use tags and view. You can even have only one tag, if you really like that, then enjoy tiling.

3.3   Configuring

My Linux distro is Gentoo. For your convenience, you can enable savedconfig USE flag and you will have a default configuration file being initialized at /etc/portage/savedconfig/x11-wm/dwm-VERSION and being pulled from that path when emerge.

When use emerge to install dwm, there is a major drawback, the configuration file can only be edited by root only and installed system-wide and single-configuration. If you are a single user, that doesnt matter; if not, you will need to manually install dwm at your own home. I am just lazy, so I use emerge and dont even bother to edit keyword file so I can use latest version.

If you need to include additional code as I do in my configuration, you put the source files at same path where dwm-VERSION at and use full path to include. Be sure to check out these patches, you might find some useful, such as new layouts.

Since you need to recompile for new configuration, that means you need to re-emerge in order to recompile. So, right now I have 99 merges history for dwm package and total merge record is 4942, which means 2% is dwm.

3.4   Status text

Its a useless feature for me, because its monochrome (there is a patch to improve, I believe) and I already have a better and working dzen system monitor. I reposition dzen to cover the status text.

3.5   About full-screen

My first trouble is program with full-screen mode, e.g. MPlayer, Flash, etc. When you enable the mode, you would see a portion of that program and you are sure the program does switch to full-screen, just other program will cover the full-screend program.

The solution is simple: 1) make the program floating, then enable the mode; or 2) switch to monocle layout, then enable the mode.

The latter method has little issue, but I wouldnt call it. The dwm bar stays on top of full-screend program. I kind of like that since I can still read my dzen system monitor.

4   Conclusion

Before I felt I need to use tiling WM, I always couldnt figure out why you want to split your screen for small areas. I have a 1680x1050 screen and I still didnt want to split it. But now I feel the programs window size isnt always affecting your working performance, it would but not entirely. In fact, split might even help the performance because you can read the reference data or whatever stuff you need alongside. You dont need to press Alt+Tab< twice just to get the information you need.

But! (There is always a but.) It might also be reducing your performance, because you can have a video playing and that would distract you. Just for the record, I have put three on at once and I hardly type anything on my keyboard.

Ever felt why pressing Alt+Tab likes an endless loop, especially when your eyes and hands dont coordinate together well after you press one more time and get past to the window you really want.

I usually have only four windows on my screen: Terminal (urxvt + tmux), Firefox (Vimperator), SMPlayer (providing beats, or distraction?), and KeepNote. Just four and I often feel I cant switch to right window efficiently, I dont use mouse to select window most of time.

I wrote a script better-alt-tab.sh using wmctrl, so I can run something like:

$ better-alt-tab.sh t

Then, terminal window will be selected. f for Firefox, m for SMPlayer or mplayer, and k for KeepNote. If runs without arguments, then it lists all windows using dzen, I dont use this function but Fluxboxs WorkspaceMenu.

Just bind it with window managers keys, in my case, the keys configuration of Fluxbox.

I recently found out you can use xinput to enable or disable an input device. I used to use synclient to disable my touchpad, or using this tricky way to disable my laptop keyboard.

The first step to get device name or id of the device:

% xinput list
 Virtual core pointer                          id=2    [master pointer  (3)]
    Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
    USB Optical Mouse                         id=8    [slave  pointer  (2)]
    SynPS/2 Synaptics TouchPad                id=7    [slave  pointer  (2)]
 Virtual core keyboard                         id=3    [master keyboard (2)]
     Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
     Sleep Button                              id=9    [slave  keyboard (3)]
     Power Button                              id=10   [slave  keyboard (3)]
     Video Bus                                 id=11   [slave  keyboard (3)]
     AT Translated Set 2 keyboard              id=6    [slave  keyboard (3)]

For touchpad, the device name is 'SynPS/2 Synaptics TouchPad' and id is 7; for keyboard, they are 'AT Translated Set 2 keyboard' and 6. Next step is to know the properties of a device:

% xinput list-props 'AT Translated Set 2 keyboard'
Device 'AT Translated Set 2 keyboard':
        Device Enabled (127):   1

This keyboard only has a property 'Device Enabled' whose value is 1, that means this keyboard is enabled. To test disabling:

sleep 0.1 ; xinput set-prop 'AT Translated Set 2 keyboard' 'Device Enabled' 0 ; sleep 5 ; xinput set-prop 'AT Translated Set 2 keyboard' 'Device Enabled' 1

The first sleep 0.1 is to prevent enter keypress being repeatedly sent somehow when you directly disable the keyboard, I am guessing when you hit the enter and the command is executed, meaning the keyboard is disabled, but the keyup event is not yet sent, so X still thinks the enter key is pressed down.

Another simple way is to use id, so you dont need long device name:

sleep 0.1 ; xinput set-prop 8 127 0 ; sleep 5 ; xinput set-prop 8 127 1

8 is id of this keyboard and 127 is the property id of 'Device Enabled'. When you list properties of device using list-props, the numbers after property names are the property ids. It seems that 'Device Enabled' always has id 127, but device id is not always the same. It depends on device attached time, who shows up first who gets next available id.

One more thing to note: I dont need root privilege to set property value.